
#pragma once

#include <iostream>
#include <map>

#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>

#include "ftplib.h"

struct camera_t {
    std::string id;
    std::string ip;
    int port;
    std::string user;
    std::string passwd;
    int channel;
};

#define LOG std::cout << __FILE__ <<" "<< __LINE__<< " " << __FUNCTION__ << " "

class ftpMgr {
public:
    static ftpMgr *instance() {
        static ftpMgr g_ftpMgr;
        return &g_ftpMgr;
    }

    int Get2Mem(std::string &strData, const char *path, const camera_t camera, off64_t offset = 0);

    void init(std::string ip, std::string user, std::string passwd, bool isSave = false);

    void Clear(const std::string ip);

public:
    boost::mutex m_ftpHandleMapLock;
    std::map<std::string, ftplib *> m_ftpHandleMap;

    bool m_isInited = false;
    std::string m_ip = "";
    std::string m_user = "";
    std::string m_passwd = "";
    bool m_isSave = false;

    ftpMgr() {}

    ftpMgr(ftpMgr const &);

    void operator=(ftpMgr const &);

};



